//////////////////////////////////////////////
//Camera.h                                  //
//The Camera class is used to to create the //
//game camera at the moment only one camera	//
//is used, however using this class it		//
//should be possible to use various cameras //
//such as for a minimap						//
//////////////////////////////////////////////
#pragma once

#ifndef CAMERAK_H
#define CAMERAK_H

#include<GLTools.h>
#include<GLMatrixStack.h>
#include"Vector3f.h"

#define THIRD_PERSON	0
#define FIRST_PERSON	1
#define	FREE_ROAMING	2

class Camerak
{
public:
	// Constuctor and destructor
	Camerak(void);
	~Camerak(void);

	// Functions that control the movement and rotation of the camera.  These generally work by manipulating 
	// the cameraFrame.
	inline void moveIn(){cameraFrame.MoveForward(movement_rate);};
	inline void moveOut(){cameraFrame.MoveForward(-movement_rate);};
	inline void strafeLeft(){cameraFrame.MoveRight(movement_rate);};
	inline void strafeRight(){cameraFrame.MoveRight(-movement_rate);};
	void moveForward();
	void moveBackward();
	inline void rotateAntiClockWise(float irotationrate){cameraFrame.RotateWorld(irotationrate,0,1,0);};
	inline void rotateUp(float irotationrate){cameraFrame.RotateLocalX(-irotationrate);};
	inline void resetForwardVector(){cameraFrame.SetForwardVector(0,0,-1);};
	inline void resetUpVector(){cameraFrame.SetUpVector(0,1,0);};

	// These functions apply the camera matrix to the scene
	void setCameraStatic(GLMatrixStack* imatrix);
	void setCameraPushMatrix(GLMatrixStack* imatrix);

	// This function is used to switch between thirs-person, first-person and free-roaming cameras.
	// These are all available in code but the actual game has no option to switch between them due
	// to strange behaviour when switching between multiple modes.
	void setCameraMode(int imode, Vector3f iorigin, float iorientation);

	// The update is used to ensure the camera remains remains in the correct position in relation to the player.
	void update(Vector3f iorigin, float iangle);

	// Functions for accessing and manipulating private or protected attributes
	inline GLFrame getFrame(){return cameraFrame;};
	inline int getCameraMode(){return camera_mode;};
	
private:
	GLFrame cameraFrame;
	M3DMatrix44f mCamera;
	float movement_rate;
	float rotation_rate;
	int camera_mode;				// Used to specify first-peron, third-person or free-roaming camera
};
#endif